package com.jushu.storbox.view.viewImpl;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;

import com.jushu.storbox.R;

public class SlipeDiceView extends View {

	private static final int DEFAULT_START = 0;
	private static final int DEFAULT_WIDTH = 200;
	private static final int DEFAULT_HEIGHT = 50;
	private static final int DEFAULT_TOTAL_WIDTH = DEFAULT_WIDTH * 2;
	private static final int DEFAULT_COLOR = 0xFF1578fb;
	private static final int DEFAULT_BACK_COLOR = 0xFFffffff;
	private static final int DEFAULT_SPEED = 0;
	
	private int slipeWidth = DEFAULT_WIDTH;
	private int slipeHeight = DEFAULT_HEIGHT;
	private int slipeColor = DEFAULT_COLOR;
	private int slipeTotalWidth = DEFAULT_TOTAL_WIDTH;
	private int slipeBackColor = DEFAULT_BACK_COLOR;

	private int slipeStart = DEFAULT_START;
	
	private Paint drawPaint;
	
 	public SlipeDiceView(Context context) {
		this(context, null);
	}
	
	public SlipeDiceView(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}
	
	public SlipeDiceView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlipeDiceView, defStyle, 0);
		slipeStart = a.getColor(R.styleable.SlipeDiceView_slipeStart, DEFAULT_START);
		slipeWidth = a.getInteger(R.styleable.SlipeDiceView_slipeWidth, DEFAULT_WIDTH);
		slipeHeight = a.getInteger(R.styleable.SlipeDiceView_slipeHeight, DEFAULT_HEIGHT);
		slipeColor = a.getInteger(R.styleable.SlipeDiceView_slipeColor, DEFAULT_COLOR);
		slipeBackColor = a.getInteger(R.styleable.SlipeDiceView_slipeBackColor, DEFAULT_BACK_COLOR);
		a.recycle();
		
		drawPaint = new Paint();
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		
		drawPaint.setStrokeWidth(slipeHeight);
		drawPaint.setStyle(Style.FILL_AND_STROKE);
		drawPaint.setColor(slipeBackColor);
		canvas.drawLine(0, 0, slipeTotalWidth, 0, drawPaint);
		
		drawPaint.setColor(slipeColor);
		canvas.drawLine(slipeStart, 0, slipeStart + slipeWidth, 0, drawPaint);
		postInvalidate();
	}
	
	public void startSlipeX(int fromX, int toX, int during) {
	}
	

	//setting \ getting method
}
